# from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.schedulers.background import BackgroundScheduler
from jsjj.mouseKeyboard.pdd.dianba.P_DB_Hyzl import *


# 输出时间
def execute(engine, conn):
    print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ',开始执行每日固定抓取动作')
    executeCatchWeb(engine, conn)


def registerDailyJob(engine, conn):
    # 每天凌晨开始抓取需要的数据
    # scheduler = BlockingScheduler()  #阻塞方式
    scheduler = BackgroundScheduler()  #非阻塞方式
    # scheduler.add_job(job, 'cron', day_of_week='1-5', hour=6, minute=30)
    # scheduler.add_job(job, 'interval', seconds=2, id='test_job1')
    # 每天执行
    # scheduler.add_job(execute, 'cron', hour='00', minute='20', second='00')
    print("====================注册每日需要运行的job====================")
    # 生产
    #scheduler.add_job(execute, 'cron', hour='00', minute='06', second='00', args=[engine, conn])
    scheduler.add_job(execute, 'cron', hour='13', minute='32', second='00', args=[engine, conn])
    scheduler.start()
